package cn.onecloud.tablet.xiaozhi.net;


import java.util.List;

import cn.onecloud.tablet.xiaozhi.model.DesktopInfo;

/**
 * 保证一个app有一个socket连接，避免每开启一个扫码页面就建立一个sockert 链接
 * Created by yin.he on 17-11-15.
 */
public final class WSThread extends Thread {

    public static boolean isConnect = true;
    public static boolean isScan = false;
    public static boolean isLogin = false;
    public static boolean isDeskgroup = false;
    public static WebSocketResult webSocketResult;

    public static DesktopInfo desktopInfo;

    public static List<DesktopInfo> desktopInfoList;

    private volatile static WSThread wsThread;

    public volatile static String uuid;

    private WSThread() {

    }

    private WSThread(String name) {
        super(name);
    }

    public static WSThread getInstance() {
        if (wsThread == null) {
            synchronized (WSThread.class) {
                if (wsThread == null) {
                    wsThread = new WSThread("websocket-link-appc");
                    wsThread.setDaemon(true);
                }
            }
        }
        return wsThread;
    }

    @Override
    public void interrupt() {
        desktopInfo = null;
        desktopInfoList = null;
        wsThread = null;
        super.interrupt();
    }


    @Override
    public void run() {
        PullResult.connectAppcc(uuid);
    }
}
